﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using Datalayer;
using Common;
using System.Data;


namespace Portal_KonTum
{
    public partial class ViewCategory : System.Web.UI.Page
    {
        IQueryMgr iq;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BinData();
            }
        }
        void BinData()
        {
            string cateid = Request.QueryString["CateID"];
            List<New> ex = new List<New>();
            
            try
            {
                iq = QueryMgr.GetDbInstance();
                Guid idc = new Guid(cateid);
                Category ca = new Category();
                ca = iq.Ca_GetCateByID(idc);
                lblCateName.Text = ca.CategoryName;
   
                idc = MethodCommon.Get_Guid(cateid);
                ex = iq.News_GetNewByCatID(idc);
                GridView1.DataSource = (ex);
                GridView1.DataBind();
             
            }
            catch(Exception exa)
            {
                Alert.Show(exa.ToString());
            }
        }
        protected void GridView1_PageIndexChanged(object sender, EventArgs e)
        {
            BinData();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;

            GridView1.EditIndex = -1;
            GridView1.SelectedIndex = -1;
        }

    }
}